/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       main_menu.h

	$Header: /game/main_menu.h $

	$NoKeywords: $

 ************************************************************************/
#ifndef MAIN_MENU_H_INCLUDED
#define MAIN_MENU_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "adventure_map_ptr.h"
#include "animation_ptr.h"
#include "bitmap_group_ptr.h"
#include "bitmap_raw_ptr.h"
#include "button.h"
#include "campaign_file_header.h"
#include "carryover_data_ptr.h"
#include "counted_thread_safe_ptr.h"
#include "game_application.h"
#include "game_window.h"

class  t_adventure_frame;
class  t_animated_window;
class  t_basic_dialog;
class  t_button;
class  t_campaign_file_ref;
enum   t_difficulty;
class  t_inflate_filter;
struct t_player_setup;

// --------------------------------------------------------
// main menu
// --------------------------------------------------------
class t_main_menu : public t_window
{
public:
	class t_item
	{
	public:
		t_item();
		
		void set( t_button* button, t_text_window*	text );
		void click();
		void lock( bool arg = true ); // prevent changes in state.
		void set_selected( bool arg );
		void set_visible( bool arg );
	protected:
		t_animated_window*	m_animation;
		t_button*			m_button;
		bool				m_locked;
		t_window*			m_still;
		t_text_window*		m_text;
	};

	t_main_menu( t_window* parent = 0 );
	virtual ~t_main_menu();

	void			click( int arg );
	void			process_command_line( t_string_keyed_array const& command_map );
	void			select( int arg );


	enum 		 { k_num_menu_items = 4 };			// How many buttons on the main menu?

protected:
	// ------------------------------------------------------------------------
	// group of related windows
	// ------------------------------------------------------------------------

	void		 create_buttons( int width );
	t_button*	 create_group( std::string const& button_name, std::string const& still_name, 
								std::string const& text, t_item& item, int index,t_button_handler handler, std::string help_keyword );
	void		 high_score_clicked();
	void		 launch_game( t_adventure_map_ptr adventure_map );
	void		 load_game_clicked( t_button * );
	virtual bool menu_click( int id );
	void		 new_game_clicked( t_button* );
	void		 options_clicked( t_button* );
	virtual void on_size_change( t_screen_rect const& rect );
	void		 quit_clicked( t_button* );
	void		 set_resolution( int width );
	void		 settings_clicked();
	void		 start_campaign();
    void         start_tutorial();
    void         start_scenario();
	void		 start_new_game();

	t_bitmap_raw_ptr								m_bitmap_raw;
	t_bitmap_group_ptr								m_bitmaps;
	t_item											m_items[k_num_menu_items];
	t_counted_ptr<t_basic_dialog>					m_join_dialog;
	t_button*										m_new_game_button;
};

void launch_new_game( t_adventure_map_ptr adventure_map );
void launch_saved_game( t_adventure_map_ptr adventure_map );
t_adventure_map_ptr read_game_file( t_window*					parent,
								    t_campaign_file_header&		file_header,
									t_campaign_file_ref const &	file_ref,
									int							map_number,
									t_difficulty				player_difficulty,
									t_player_setup*				player_setup_ptr,
									int							turn_duration_index,
									t_carryover_data_ptr		carryover_data,
									bool						guards_move );
t_adventure_map_ptr read_new_game( t_window* parent );
t_adventure_map_ptr read_next_scenario( t_window* parent, t_adventure_map & map, bool * no_more_maps = NULL );
t_adventure_map_ptr read_restarted_game( t_window* parent, t_adventure_map* map );
t_adventure_map_ptr read_saved_game( t_window* parent );
bool				start_new_campaign( t_adventure_map_ptr & adventure_map );
void				verify_external_strings();
void file_open_failure( t_campaign_file_ref const & file_ref );
std::vector< t_player_setup > create_default_player_setup_vector( t_map_header const &	map_header );

#endif // MAIN_MENU_H_INCLUDED
